home *** CD-ROM | disk | FTP | other *** search
- /*
- * postSx.x
- *
- * Author : D.N kit.iizuka
- * Created: 1993 12/15(Wed)
- */
-
- #include "common.h"
- #include <string.h>
- #include <stdlib.h>
- #include <method/Control_i.h>
- #include <method/Dialog_i.h>
- #include <method/Dos_i.h>
- #include <method/Graph_i.h>
- #include <method/Memory_i.h>
- #include <method/Task_i.h>
- #include <method/Window_i.h>
- #include <method/Event_i.h>
- #include <method/_methodSx.h>
- #include <method\methodsx.h>
-
- /* #include <method\methodSx.h>
- #include <method\sxlib.h>
- */
- #define SXVERSION 0x110 /* SXのバージョンチェック用 */
- #define VERSTR "1.00" /* バージョン番号 */
-
- #define MAIN_DX 300 /* メインウインドウの横幅 */
- #define MAIN_DY 230 /* メインウインドウの縦幅 */
- #define MAIN_ID 49 /* メインウインドウの種類 */
- #define MAIN_OPT WC_GBOX /* メインウインドウの付属品 */
-
- /* QueryError用 */
- #define rectQE Rect(10, 30, 240, 160)
-
- /*
- * 関数宣言
- */
-
- void SaveComLine();
- int MyIconify();
-
- int PostMain(char *opt);
- void PostTini();
- /* void InitTable(); */
-
- int MainDraw(void);
- void WhoAmI(void);
- int PostMenuProc(void);
- int TableMenuProc(void);
- int LCCBtnProc();
- int ExecCommand();
- int FnameProc();
- int EscCancel(method_t *tm);
- int InputFile(void);
- int Dropped();
- int DrawDialog(void);
- int CopyMidasi(void);
- /* int CopyAll(void); */
- int CopyBeneath(void);
- int DispHonbun(int);
- int DoSelect(void);
- int SxBasic(void);
- void MainLoop(void);
- int Init(void);
- void Tini(void);
- /* kenji */ int main( int , char *[] );
- int DoMenukensaku( void );
-
- /* グローバル変数 各ファイル共通 */
- int cdfile;
- int tableMax;
- int limit;
- unsigned int indexpage , indexoff; /* kenji suzuki */
- int searchMode;
-
- char *tablePostNo[MAX_TABLE_POST_NO]; /* 項目名 */
- unsigned int tableFilePos[ MAX_TABLE_POST_NO ]; /* kenji suzuki ファイルないの位置 */
-
- /* 現在のモード 0 = ファイル未指定 1 = カタログファイルオープン中 2 = 文献ファイルオープン中(通常検索) */
- int oprateMode;
-
-
- /* 外部参照 */
- /* extern unsigned short menupage_st; */ /* メニューが始まるページ */
- /* extern unsigned short menupage_ed; */ /* メニューが終わるページ */
-
- /* グローバル変数 このファイルのみ */
- static char searchAddress[100]; /* 検索した住所 */
- char fname[258] = "\0"; /* ファイル名格納用 */
- char oldfname[258] = "\0";
- char title[32];
- char *bunkenFile; /* 実際に開いたファイル名 */
- static int command = 0; /* 現在処理中のコマンド */
-
- /*
- * 描画ルーチンリスト
- */
- proc_list_t
- mainDraw = {MainDraw, NULL /* リスト終了 */};
-
- /*
- * ウインドウ定義
- */
- window_t mainWin = {
- &mainDraw, (window *) NULL, (window *) -1, {0, 0, MAIN_DX, MAIN_DY},
- "\@[電子ブック] 検索", 0, (MAIN_ID << 4) + MAIN_OPT, 0b1001
- };
-
- /*
- * 各種Methodの内容定義
- */
- char menuStr[] = {
- "^Hこのプログラムは..,"
- "^Fファイルを開く,"
- "~,"
- "^W本文の全クローズ,"
- "~,"
- "^Iアイコン化,"
- "^Q終了"
- };
- char menuStr2[] = {
- " コピー,"
- "~,"
- "^A全選択,"
- "^D全選択解除"
- };
-
- m_menu_t
- menuPost = {{0, -20, 1024, 1024}, 0b0001, "\@電子ブック検索", (long) menuStr , NULL}, /* メイン用 */
- menuTable = {{0, 0, 10, 10} , 0b0001, 0 , (long) menuStr2, NULL}; /* 表選択用(ここでのrectは適当な値) */
-
- char address[200];
- m_text_t
- addressm = {address, 190, {4, 10, 4 + 224 , 10 + 16}, 1, 0, 0, 0,
- G_BLACK, G_WHITE, 0b101001, NULL, 1},
- fnameTM = { /* ksuzuki ファイル名入力用 */
- fname, 90, {60, 60, 60 + 6*30, 60 + 12},
- 0, 0, 0, Point_t(0, 0), G_BLACK, G_WHITE,
- 0b01011, EscCancel, 0
- };
-
- char *titleLC[2] = {"\@実行", "\@中止"};
- point_t ptLC[2] = {Point_t(150, 128), Point_t(200, 128)};
- m_chrbtns_t loadCancelCBM = {
- ptLC, /* @配置左上座標の配列へ */
- titleLC, /* @文字列へのポインタの配列へ ※LASCII */
- 2, /* @ボタン総個数 */
- 0, /* @休止状態フラグ */
- };
-
- m_control_t
- search = {{242, 10 , 242 + 6*6 + X_STDBTN, 10 + DY_STDBTN}, 0, 0, 1, 0, "\@検索"},
- select = {{300-100, 230-20, (300-100) + 6*8 + X_STDBTN, (230-20) + DY_STDBTN}, 0, 0, 1, 0, "\@選択"},
- menuken = {{242, 34 , 242 + 6*6 + X_STDBTN, 34 + DY_STDBTN}, 0, 0, 1, 0, "\@メニュー"};
-
- m_table_t
- noSelect = {0, 0, 0, 0b01010, 1, 0, Point_t(4, 90), tablePostNo, NULL};
-
- char *sxbCom[4] = {"SEARCH", "ZENKAKU", "HANKAKU", "QUIT"};
- m_sxbasic_t
- sxbasic = {4, sxbCom, 0b0000};
- /* noSelect.tbValue */
-
- /* kenji */
- char *week2[] = { "\@前方一致", "\@後方一致", "\@完全一致"},
- *week1[] = { "\@EB/EBXA", "\@EBG"};
-
- m_udmenu_t
- week2UDM = {3,10,week2, 1, 0,
- Point_t(120,34) },
- week1UDM = {2,10,week1, 1, 0,
- Point_t(4,34) };
-
- /*
- * Method定義
- */
- method_t
- mMenu = {NULL, m_MENU, (m_control_t *) &menuPost, PostMenuProc},
- mTMenu = {NULL, m_MENU, (m_control_t *) &menuTable, TableMenuProc},
- mAddress = {NULL, m_STRING, (m_control_t *) &addressm, NULL},
- mSearch = {NULL, m_STDBTN, &search, NULL},
- mSelect = {NULL, m_STDBTN, &select, DoSelect},
- mMenuken = {NULL, m_STDBTN, &menuken, DoMenukensaku},
- /* mZenkaku = {NULL, m_OTNBTN, &zenkaku, (proc_t) -1}, */
- mSxBasic = {NULL, m_SXBASIC, (m_control_t *) &sxbasic, SxBasic},
- mNoSelect ={NULL, m_TABLE, (m_control_t *) &noSelect, (proc_t) -1},
- mWeek2UDM = {NULL, m_UPDMENU, &week2UDM, (proc_t) -1}, /* kenji */
- mWeek1UDM = {NULL, m_UPDMENU, &week1UDM, (proc_t) -1}, /* kenji */
- mDropDM = {NULL, m_DRPDWN, NULL, Dropped},
- mLCCBM = {NULL, m_CHRBTNS, &loadCancelCBM, LCCBtnProc},
- mFnameTM = {NULL, m_STRING, &fnameTM, FnameProc},
- mDialogDM = {NULL, m_DRAWWIN, DrawDialog, (proc_t) -1},
- /* Methodグループ */
- /* *mgAll[] = {&mAddress, &mSxBasic, &mSearch, &mCopy, &mCopyBen, &mZenkaku , &mNoSelect, &mMenu , &mWeekUDM , &mDropDM , NULL}; */
- *mgAll[] = {&mAddress, &mSxBasic, &mSearch, &mSelect , &mMenuken , &mNoSelect, &mWeek2UDM, &mWeek1UDM , &mMenu , &mDropDM , NULL};
- method_t *dialogMG[] = {&mDialogDM, &mFnameTM, &mLCCBM, NULL};
-
- /* 参考 t_query.c */
- /* QueryError を利用した疑似ダイアログの為の用意 */
-
- int EventForQE(order_t order)
- {
- switch (order.ev) {
- case EV_CLOSEALL:
- case EV_CLOSEWIN:
- return order.ev; /* そのままイベント内容を返す */
- }
- /* 他のイベントは全て無視 */
- return 0;
- }
-
-
- /*
- * 描画関数定義
- */
- void DrawAddress()
- {
- char num[ 28 ];
- int pen = GMPenMode(G_BACK);
-
- if (kouhocount > 0)
- {
- ULUsingL( num , (int)kouhocount , 5 );
- strcat( num , " 件" );
- } else {
- strcpy( num , " 一致する項目はありません" );
- };
- GMFillRect(&Rect(60, 66, 1024, 66 + 12));
- GMPenMode(pen);
- ULBlackStrZ( num , Point_t(60, 66));
- }
-
- int MainDraw()
- {
- ULD3LineH(Point_t(0, 58), Point_t(1024, 0), 1);
- /* ULBlackStrZ("(", Point_t(4, 66));
- ULBlackStrZ(")", Point_t(182, 66)); */
- ULBlackStrZ("検索結果:", Point_t(4, 66));
- DrawAddress();
- GMPenMode(G_BACK);
- GMBackColor(G_LGRAY);
- GMFillRect(&Rect(4 - 2, 90 - 2, 1024, 1024)); /* 表を消す */
- return 0;
- }
-
-
- /*
- * Methodのコールバック
- */
- /* メニュー処理 */
- void WhoAmI()
- {
- GMShadowStrZ( "このプログラムは・・・", Point_t(64,4) );
- ULBlackStrZ( "このプログラムは、電子ブックを", Point_t(20,36) );
- ULBlackStrZ( "検索します。", Point_t(20,50) );
- ULBlackStrZ( " version 1.30 : 鈴木 健児", Point_t(8,68) );
- DMBeep(2);
- }
- int PostMenuProc()
- {
- int i , j , max , value;
-
- switch (menuPost.mValue) {
- case 1:
- ULWhoAmI(WhoAmI);
- break;
- case 2:
- InputFile();
- break;
- case 4:
- TskAllClose();
- break;
- case 6:
- if (MyIconify() < 0)
- return EV_CLOSEALL;
- break;
- case 7:
- return EV_CLOSEALL;
- }
- return 1;
- }
-
- int TableMenuProc()
- {
- int i , j , max , value;
-
- switch (menuTable.mValue) {
- case 1:
- CopyMidasi( );
- break;
- case 3:
- value = 0;
- i = 1; /* マスク */
- if( noSelect.tbMax > 32 )
- {
- max = 32;
- } else {
- max = noSelect.tbMax;
- };
- for(j=0;j<max;j++) /* 1~32行目を調べる */
- {
- value += i;
- i = i << 1; /* マスクを左にシフト */
- }
- noSelect.tbValue = value;
- if( noSelect.tbMax > 32 ) /* 32行目以降を調べる */
- {
- for(j=32;j<(noSelect.tbMax);j++) /* 1~32行目を調べる */
- {
- *(tablePostNo[ j ]) = 1;
- };
- };
- ReinitTBM(&mNoSelect);
- SetWinGraph(&mainWin);
- DrawMethod(&mNoSelect);
- break;
- case 4:
- noSelect.tbValue = 0;
- if( noSelect.tbMax > 32 ) /* 32行目以降を調べる */
- {
- for(j=32;j<(noSelect.tbMax);j++) /* 1~32行目を調べる */
- {
- *(tablePostNo[ j ]) = 0;
- };
- };
- ReinitTBM(&mNoSelect);
- SetWinGraph(&mainWin);
- DrawMethod(&mNoSelect);
- break;
- }
- return 1;
- }
-
- /* メニュー検索用のウィンドウを起動 */
- int DoMenukensaku( )
- {
- int stat;
-
- if( mpagenumber != 0 )
- {
- stat = printout2( 1 , (mpagenumber-1)*0x800 );
- if( stat == 2 )
- {
- return( 65535 );
- };
- };
-
- return( 1 );
- }
-
- /*
- * ファイルアイコンがウインドウにドロップされると
- * ESC+fと同等の処理をアイコンのファイル名に対して行う
- */
- int Dropped()
- {
- char sbuf[258];
- if (ULGetDroppedFile(sbuf) <= 0) {
- QueryError(1, "ファイル名が\0分からんぎゃあ(名古屋弁)\0\0" , (proc_t) EventForQE, &mainWin, &rectQE);
- return -1;
- };
-
- TSEndDrag(0);
- strcpy(oldfname, fname);
- strcpy(fname, sbuf);
- command = 'F';
- ExecCommand();
- DrawMethod(&mAddress);
- return 1; /* このMethodの処理をした */
- }
-
- /*
- * ESCでキャンセルするフィルタ関数
- */
- static int flgCancel = false;
- int EscCancel(method_t *tm)
- {
- int key = KeyOfEvent(&curEvRec);
- flgCancel = false;
- if (key == '\033') { /* ESCコード? */
- flgCancel = true;
- return 2; /* このMethodの入力 */
- }
- return 0; /* フィルタは何もしていない */
- }
-
- /*
- * 疑似ダイアログ描画関数
- */
- rect imgDialog = {20, 20, 280, 160},
- lcBtns = {150-14, 128-4, 236+14, 128+DY_STDBTN+8};
- static char
- *fsMsg = "フォントサイズ変更:",
- *fMsg = "ロードファイル名を入力",
- *wMsg = "新規保存ファイル名を入力";
- int DrawDialog()
- {
- char *msg = NULL;
- GMShadowRect(&lcBtns);
- switch (command) {
- case 'F':
- msg = fMsg; break;
- }
- if (msg) /* 現在のコマンドに応じてメッセージを添える */
- GMShadowStrZ(msg, Point_t(65, 40));
- /* それぞれのコマンドでもっと描かなければならないならここでかく */
- /* switch (command) {
- case 'F':
- ULBlackStrZ("X:", Point_t(30, 60+2));
- ULBlackStrZ("Y:", Point_t(30, 88+2));
- break;
- } */
- return 0;
- }
-
- int ShowErr( char *fname )
- {
- int len;
- char mesQE[ 260 ] = "ファイルが開けません";
- /* 01234567890123456789012 1 */
-
- mesQE[ 20 ] = '\0';
- strcpy( &mesQE[ 21 ] , fname );
- len = strlen( fname );
- mesQE[ 21 + len ] = '\0';
- mesQE[ 21 + len + 1 ] = '\0';
-
- QueryError(1, mesQE , (proc_t) EventForQE, &mainWin, &rectQE);
-
- return( 0 );
- }
-
- /*
- * コマンド実行
- */
- int ExecCommand()
- {
- int ret = false;
- int stat;
- int len;
- char wintitle[ 40 ];
-
- if (!flgCancel) { /* キャンセルでは終了していない */
- switch (command) {
- case 'F': /* 文献ファイル入力 */
- /* パス名の解析 */
- stat = checkFile( fname );
- if( stat == 1 ) /* カタログファイル */
- {
- stat = read_catalog( fname );
- if( stat >= 0 )
- {
- oprateMode = 1;
- noSelect.tbMax = tableMax;
- noSelect.tbValue = 0;
- ReinitTBM(&mNoSelect);
- SetWinGraph(&mainWin);
- strcpy( wintitle+1 , "[カタログ]" );
- wintitle[ 0 ] = 10;
- WMTitleSet( mainWin.wptr , wintitle );
- SleepMethod( &mMenuken , 1 );
- DrawMethod(&mNoSelect);
- DrawAddress();
- EMDeCross();
- } else {
- ShowErr( fname );
- flgCancel = true;
- ret = true;
- };
- } else if( stat == 3 ) /* カタログファイル */
- {
- stat = read_catalogEP( fname );
- if( stat >= 0 )
- {
- oprateMode = 1;
- noSelect.tbMax = tableMax;
- noSelect.tbValue = 0;
- ReinitTBM(&mNoSelect);
- SetWinGraph(&mainWin);
- strcpy( wintitle+1 , "[カタログ]" );
- wintitle[ 0 ] = 10;
- WMTitleSet( mainWin.wptr , wintitle );
- SleepMethod( &mMenuken , 1 );
- DrawMethod(&mNoSelect);
- DrawAddress();
- EMDeCross();
- } else {
- ShowErr( fname );
- flgCancel = true;
- ret = true;
- };
- } else if(( stat == 2 ) || ( stat == 4 )) /* 文献ファイル */
- {
- stat = CdFileOpen( fname , oldfname );
- if( stat >= 0 )
- {
- /* ウィンドウタイトルの作成 */
- if( w_key == 1 )
- {
- stat = get_titleEP( fname , title );
- } else {
- stat = get_title( fname , title );
- };
- if( stat == 0 )
- {
- if( e_key == 0 )
- {
- convJis( title );
- };
- wintitle[ 1 ] = '[';
- wintitle[ 2 ] = '\0';
- strcat( wintitle+1 , title );
- strcat( wintitle+1 , "] 検索" );
- wintitle[ 0 ] = strlen( title ) + 7;
- } else {
- strcpy( wintitle+1 , "[電子ブック] 検索" );
- wintitle[ 0 ] = 17;
- };
- WMTitleSet( mainWin.wptr , wintitle );
-
- InitTable();
- oprateMode = 2;
- noSelect.tbMax = tableMax;
- noSelect.tbValue = 1;
- ReinitTBM(&mNoSelect);
- SetWinGraph(&mainWin);
-
- if( mpagenumber != 0 )
- {
- AwakeMethod( &mMenuken , 1 );
- } else {
- SleepMethod( &mMenuken , 1 );
- };
- DrawMethod(&mNoSelect);
- DrawAddress();
- EMDeCross();
- bunkenFile = fname;
- } else {
- ShowErr( fname );
- strcpy(fname , oldfname );
- flgCancel = true;
- ret = true;
- };
- } else {
- flgCancel = true;
- ret = true;
- };
- break;
- }
- }
- /* MMHdlDispose(tex); */
- flgCancel = false;
- return ret;
- }
-
- /*
- * 実行/中止ボタンの処理
- */
- int LCCBtnProc()
- {
- if (2 == loadCancelCBM.cbValue) /* 中止ボタン */
- flgCancel = true;
- else
- flgCancel = false;
-
- /* if (command != 'F') */
- return FnameProc();
- /* ExecCommand(); */ /* 実行ボタンが押された(文字大調節) */
- /* CloseQuery(&mainWin, false);
- ActivateTMethod(&mAddress, &mainWin);
- DrawWindow(&mainWin);
- */ return 1;
- }
-
- /*
- * ファイル名の入力の処理
- */
- int FnameProc()
- {
- int flg = flgCancel;
- SaveMethod(&mFnameTM);
- CloseQuery(&mainWin, flg);
- command = 'F';
- ExecCommand(); /* ファイル名の入力が終了 */
- /* if (!flg) */
- DrawWindow(&mainWin);
- ActivateTMethod(&mAddress, &mainWin);
-
- return 1;
- }
-
- int InputFile()
- {
- strcpy(oldfname, fname); /* 現在開いているファイル名を保存 */
- command = 'F';
- OpenQuery(&mainWin, &imgDialog, dialogMG);
- ClipOnQuery(&mainWin, false);
- SetSelectTM(&mFnameTM);
- ActivateTMethod(&mFnameTM, &mainWin); /* ファイル名入力開始 */
- ClipOnContents(&mainWin);
- if (command)
- return 1; /* textに対するこのキー入力は無視して良い */
- return 0; /* キー入力処理を続けて下さい */
- }
-
- int DoSelect( void )
- {
- int line;
- int len;
- int stat;
- int i,j;
- char fname2[ 258 ];
- char path[ 10 ];
-
- if( oprateMode == 1 ) /* 文献ファイルのオープン */
- {
- line = 0;
- i = 1; /* マスク */
- for(j=0;j<32;j++) /* 1~32行目を調べる */
- {
- if( (i & noSelect.tbValue) > 0 )
- {
- line = j + 1;
- };
- i = i << 1; /* マスクを左にシフト */
- }
- if( noSelect.tbMax > 32 ) /* 32行目以降を調べる */
- {
- for(j=32;j<(noSelect.tbMax);j++) /* 1~32行目を調べる */
- {
- if( *(tablePostNo[ j ]) == 1 )
- {
- line = j + 1;
- };
- };
- };
- if( line > 0 )
- {
- if( w_key == 1 )
- {
- stat = get_pathEP( fname , line , path );
- strcpy(oldfname, fname);
- /* ファイル名の作成 */
- fname2[ 0 ] = 0;
- strncpy( fname2 , fname , 3 ); /* ドライブ名 「F*\」 */
- fname2[ 3 ] = 0;
- strcat( fname2 , path ); /* ディレクトリ名 */
- strcat( fname2 , "\\data\\honmon" ); /* ファイル名 「\START」*/
- } else {
- stat = get_path( fname , line , path );
- strcpy(oldfname, fname);
- /* ファイル名の作成 */
- fname2[ 0 ] = 0;
- strncpy( fname2 , fname , 3 ); /* ドライブ名 「F*\」 */
- fname2[ 3 ] = 0;
- strcat( fname2 , path ); /* ディレクトリ名 */
- strcat( fname2 , "\\start" ); /* ファイル名 「\START」*/
- };
- if( stat >= 0 )
- {
- fname[ 0 ] = 0;
- strcpy( fname , fname2 );
- command = 'F';
- ExecCommand();
- ActivateTMethod(&mAddress, &mainWin);
- } else {
- ShowErr( fname2 );
- };
- };
- } else if( oprateMode == 2 )
- {
- i = 1; /* マスク */
- for(j=0;j<32;j++) /* 1~32行目を調べる */
- {
- if( (i & noSelect.tbValue) > 0 )
- {
- stat = DispHonbun( j + 1 );
- };
- i = i << 1; /* マスクを左にシフト */
- }
- if( noSelect.tbMax > 32 ) /* 32行目以降を調べる */
- {
- for(j=32;j<(noSelect.tbMax);j++) /* 1~32行目を調べる */
- {
- if( *(tablePostNo[ j ]) == 1 )
- {
- stat = DispHonbun( j + 1 );
- };
- };
- };
- };
-
- return( 1 );
- }
-
- int DispHonbun( int line )
- {
- int stat;
-
- if( oprateMode == 2 )
- {
- if( tablePostNo[ line-1 ] != NULL && tableFilePos[ line-1 ] != NULL )
- {
- stat = printout2( line-1 , tableFilePos[ line-1 ] );
- if( stat == 2 )
- {
- return( 65535 );
- };
- };
- };
- return( 1 );
- }
-
-
- /* 見出しをテキストスクラップへ */
- int CopyMidasi()
- {
- char *st;
- char *buff, *sstr, *dstr;
- int siz = 0, i;
- int j,k;
-
- if (0 == noSelect.tbMax) {
- QueryError(1, "まず検索して下さい!\0\0" , (proc_t) EventForQE, &mainWin, &rectQE);
- return 1;
- }
- /* 必要なバッファサイズを割り出す */
- i = 1; /* マスク */
- for(j=0;j<32;j++) /* 1~32行目を調べる */
- {
- if( (i & noSelect.tbValue) > 0 )
- {
- siz += 8 + strlen( tablePostNo[ j ] ); /* 8はさばよみ */
- };
- i = i << 1; /* マスクを左にシフト */
- }
- if( noSelect.tbMax > 32 ) /* 32行目以降を調べる */
- {
- for(j=32;j<(noSelect.tbMax);j++) /* 1~32行目を調べる */
- {
- if( *(tablePostNo[ j ]) == 1 )
- {
- st = tablePostNo[j] + 1;
- siz += 8 + strlen( st ); /* 8はさばよみ */
- };
- };
- };
- if ((buff = _ULMALLOC(siz + 1)) == NULL) {
- QueryError(1, "作業用メモリが足りません!\0\0" , (proc_t) EventForQE, &mainWin, &rectQE);
- return 1;
- }
- /* 文字列を作り上げる */
- dstr = buff;
- i = 1; /* マスク */
- for(j=0;j<32;j++) /* 1~32行目を調べる */
- {
- if( (i & noSelect.tbValue) > 0 )
- {
- sstr = tablePostNo[j];
- k = strlen( sstr );
- strcpy( dstr , sstr );
- dstr += k;
- *dstr++ = 0xd;
- *dstr++ = 0xa;
- };
- i = i << 1; /* マスクを左にシフト */
- }
- if( noSelect.tbMax > 32 ) /* 32行目以降を調べる */
- {
- for(j=32;j<(noSelect.tbMax);j++) /* 1~32行目を調べる */
- {
- if( *(tablePostNo[ j ]) == 1 )
- {
- sstr = tablePostNo[j] + 1;
- k = strlen( sstr );
- strcpy( dstr , sstr );
- dstr += k;
- *dstr++ = 0xd;
- *dstr++ = 0xa;
- };
- };
- };
- *dstr = '\0';
- ULStrToTMScrap(buff);
- _ULFREE(buff);
- return 1;
- }
-
- /* SX-BASICで送信された時 */
- int SxBasic()
- {
- /* char **com, **com2;
- switch (sxbasic.sxbValue) {
- case 1: */ /* SEARCH */
- /* com = sxbasic.sxbCommand;
- com2= sxbasic.sxbCommand2;
- if (com[0][6]) */ /* comにオプションもついていた */
- /* strncpy(address, &com[0][6], 100);
- else if (!com2) */ /* com2に格納されていた */
- /* strncpy(address, *com2, 100);
- ULStrAdjustLeft(address);
- ChangeTextTM(&mAddress, address);
- SetSelectTM(&mAddress);
- return (int) &mAddress; *//* これで十分実行してくれる */
- /* case 2: */ /* ZENKAKU */
- /* ValueSetCM(&zenkaku, 1); */
- /* break;
- case 3: */ /* HANKAKU */
- /* ValueSetCM(&zenkaku, 0); */
- /* break;
- case 4: */ /* QUIT */
- /* return EV_CLOSEALL;
- } */
- return 1;
- }
-
- /* 表選択用メニューが出る範囲を変更 */
- int ChRectTMenu( void )
- {
- GetWholeRectTBM(&noSelect, &menuTable.mRect);
- ChainAMethod( NULL , &mainWin , &mTMenu ); /* 先頭に登録 */
-
- return( 0 );
- }
-
- /* */
- int MoveBtn( void )
- {
- point_t size = ULGetSizeWindow(mainWin.wptr);
-
- size = (point_t)ULAddPoint( size , Point_t( -100 , -20 ) );
- select.cRect = Rect( Pt_x(size), Pt_y(size), Pt_x(size) + 6*8 + X_STDBTN, Pt_y(size) + DY_STDBTN );
- CMMove( select.cHdl , size );
-
- return( 0 );
- };
-
- /* 結果表示用表選択Methodの大きさを変える */
- void InViewTable()
- {
- point_t size = ULGetSizeWindow(mainWin.wptr),
- a_col_siz = GetASizeTBM(&noSelect);
- noSelect.tbHMax = (Pt_x(size) - Pt_x(noSelect.tbPt) - DY_SLDVOL) / Pt_x(a_col_siz) - 2;
- noSelect.tbVMax = (Pt_y(size) - Pt_y(noSelect.tbPt) - DY_SLDVOL) / Pt_y(a_col_siz);
- }
-
- /* 結果表示用表選択Methodの大きさを変え、表示し直す領域を設定する
- * 実際には直後にUPDATEが起こるので描き直しはしない */
- point_t preWinSize;
- void InViewTable2()
- {
- point_t tbpt, p1, p2, pp1, pp2, pwsz, wsz = ULGetSizeWindow(mainWin.wptr);
- int top = GetTopTBM(&noSelect);
- rect rct, prct, tr;
-
- /* 計算前の値を持っておく(以前のウインドウの大きさの時の値) */
- GetRect2TBM(&noSelect, noSelect.tbVMax - 1, &prct);
-
- InViewTable();
- ReinitTBM(&mNoSelect);
- SetTopTBM(&noSelect, top);
-
- SetWinGraph(&mainWin);
- if (GetTopTBM(&noSelect) < top) {
- /* 大きくなりすぎて表示再上値が小さくなった → 全て描き直す */
- GetWholeRectTBM(&noSelect, &rct);
- *(point_t *) &rct.left = GMLocalToGlobal(*(point_t *) &rct.left);
- *(point_t *) &rct.right = GMLocalToGlobal(*(point_t *) &rct.right);
- /* 表全体の大きさを得、それをグローバル座標系に直した */
- WMAddRect(&rct);
- }
- /* 表の右辺と底辺付近をアップデート領域にする */
- GetRect2TBM(&noSelect, noSelect.tbVMax - 1, &rct);
- tbpt = GMLocalToGlobal(noSelect.tbPt);
- p1 = GMLocalToGlobal(Pt_t(rct.left, rct.top));
- p2 = GMLocalToGlobal(Pt_t(rct.right, rct.bottom));
- pp1 = GMLocalToGlobal(Pt_t(prct.left, prct.top));
- pp2 = GMLocalToGlobal(Pt_t(prct.right, prct.bottom));
- pwsz = GMLocalToGlobal(preWinSize);
- preWinSize = wsz;
- wsz = GMLocalToGlobal(wsz);
- /* 横 */
- if (Pt_y(pwsz) < Pt_y(wsz))
- /* 前より幅は広くなった */
- tr = Rect(Pt_x(tbpt)-2, Pt_y(pp1)-2, Pt_x(pwsz) - 18, Pt_y(pwsz));
- else
- /* 前より幅は狭くなった */
- tr = Rect(Pt_x(tbpt)-2, Pt_y(p1)-2, Pt_x(wsz) - 18, Pt_y(wsz));
- WMAddRect(&tr);
- /* 縦 */
- if (Pt_x(pwsz) < Pt_x(wsz))
- /* 前より幅は広くなった */
- tr = Rect(Pt_x(pp2) - 12, Pt_y(tbpt)-2, Pt_x(pwsz), Pt_y(pwsz) - 18);
- else
- /* 前より幅は狭くなった */
- tr = Rect(Pt_x(p2) - 12, Pt_y(tbpt)-2, Pt_x(wsz), Pt_y(wsz) - 18);
- WMAddRect(&tr);
- /* 18 はグローボックスまで書き直したくないので */
- /* 12 はさば読みで多めに領域を設定したいので */
-
-
- /* 表選択用メニューが出る範囲を変更 */
- UnchainAMethod( &mTMenu ); /* いったんチェインをはずす */
- ChRectTMenu( );
- MoveBtn( );
- }
-
-
- void MainLoop()
- {
- char エラーメッセージ[100];
- short エラーが起こった = false;
- order_t order = {0};
- char workbuf[ 80 ];
-
- preWinSize = ULGetSizeWindow(mainWin.wptr);
- while (true) {
- order.ev = MayIHelpYou();
- switch (order.ev) {
- case EV_WINZMIN:
- case EV_WINZMOUT:
- case EV_WINGROW:
- InViewTable2();
- break;
- case EV_ICONIFY:
- if (MyIconify() < 0)
- return;
- break;
- case EV_SAVE:
- SaveComLine();
- break;
- case EV_EXITTSK:
- if( curEvRec.what2 == EXITTSK )
- {
- /* int counter;
- counter = maxTskTable;
- while( --counter >= 0 )
- {
- if( tskTable[ counter ] == curEvRec.whom );
- {
- ULError_int( tskTable[ counter ] );
- tskTable[ counter ] == 0;
- };
- };
- */ };
- break;
- case EV_NOTICEENDTSK: /* ken */
- break;
- case EV_CLOSEALL:
- case EV_CLOSEWIN:
- SaveComLine();
- return; /* 終了指令ならメインループ終了 */
- case EV_UNDEFINED:
- /* if( oprateMode > 1 )
- {
- if(( curEvRec.what == E_SYSTEM1 ) || ( curEvRec.what == E_SYSTEM2 ))
- {
- if( curEvRec.what2 == NOTICEEJECT )
- {
- DMError( 1, "イジェクト" );
- };
- if( curEvRec.what2 == DISKINSERT )
- {
- DMError( 1, "インサート" );
- };
- };
- };
- */ break;
- default:
- if (order.mth == &mAddress
- || order.mth == &mSearch) {
- SaveMethod(&mAddress);
- if( oprateMode != 2 )
- {
- QueryError(1, "文献ファイルを\0指定してください\0\0" , (proc_t) EventForQE, &mainWin, &rectQE);
- break;
- }
-
- if (!address[0]) {
- QueryError(1, "検索する文字列を\0入力して下さい !!\0\0" , (proc_t) EventForQE, &mainWin, &rectQE);
- break;
- }
- EMEnCross(0);
- searchMode = week2UDM.umValue;
- e_key = week1UDM.umValue - 1;
- InitTable();
- Eb_Main(address); /* リターンキーか, 検索ボタンで検索開始 */
- if (エラーが起こった) {
- ULError_str("eb_sx.x:", エラーメッセージ);
- noSelect.tbMax = 0;
- noSelect.tbValue = 0;
- } else {
- noSelect.tbMax = tableMax;
- noSelect.tbValue = 0;
- strcpy( workbuf , address );
- menuStr[ 10 ] = workbuf;
- /* */
- }
- ReinitTBM(&mNoSelect);
- SetWinGraph(&mainWin);
- DrawMethod(&mNoSelect);
- DrawAddress();
- EMDeCross();
- }
- }
- }
- }
-
- int Init()
- {
- /* 文字列テーブルを初期化 */
- /* InitTable(); */
- tableMax = 0;
- /* 結果表示部分を補正 */
- InViewTable();
- /* 検索住所をクリア */
- searchAddress[0] = '\0';
- kouhocount = 0;
- return 0;
- }
-
- void Tini()
- {
- /* PostTini(); */
- }
-
- rect maxmin = {MAIN_DX, MAIN_DY, 740, 500};
- int main(int argc, char *argv[])
- {
- int i;
- unsigned char *argv0;
- argv0 = (unsigned char *) argv[0];
-
- #ifdef SXVERSION
- if (SXVERSION > SXVer()) {
- QueryError(1,"SX-Window system の\0バージョンが古すぎます(1.10以上)\0\0" , (proc_t) EventForQE, &mainWin, &rectQE);
- return( 0 );
- }
- #endif /* SXVERSION */
-
- /* コマンドライン判定. 余り使われないであろうから簡単にしてある */
- for (i = 1; i < argc; i++) {
- switch (argv[i][0]) {
- case '/':
- case '-':
- if( ('A' == argv[i][1]) || ('a' == argv[i][1]) )
- {
- a_key = 1;
- week2UDM.umValue = 3;
- } else if( ('R' == argv[i][1]) || ('r' == argv[i][1]) )
- {
- r_key = 1;
- week2UDM.umValue = 2;
- } else if( ('E' == argv[i][1]) || ('e' == argv[i][1]) )
- {
- e_key = 1;
- week1UDM.umValue = 2;
- } else if( ('F' == argv[i][1]) || ('f' == argv[i][1]) )
- {
- ULStrcpy( fname , &argv[i][2] );
- } else if( ('S' == argv[i][1]) || ('S' == argv[i][1]) )
- {
- ULStrcpy( address , &argv[i][2] );
- /* } else if( 'w' == argv[i][1])
- {
- ;
- */ };
- break;
- default:
- ULStrcpy(address, argv[i]);
- break;
- }
- }
-
- if (isIconified())
- if (MyIconify() < 0)
- Tini();
-
- if (OpenWindow(&mainWin, -100)) {
- ULError( "ウインドウさえ開きません" );
- return(1);
- } /* ウインドウを開く */
- if (Init() < 0) /* 初期化 */
- return(0);
- oprateMode = 0;
-
- /* maxTskTable = 0; */
-
- /* CdFileOpen( ); */
- SetWinGrowSize(&mainWin, &maxmin); /* ウインドウの最大最小大きさを指定 */
- ChainMethodIn(&mainWin, mgAll); /* Methodを登録する */
-
- ChRectTMenu( ); /* 後から表選択用メニューMethodを登録 */
- SleepMethod( &mMenuken , 1 );
-
- if( a_key == 1 )
- {
- week2UDM.umValue = 3;
- };
- if( r_key == 1 )
- {
- week2UDM.umValue = 2;
- };
- if( e_key == 1 )
- {
- week1UDM.umValue = 2;
- };
-
- SetSelectTM(&mAddress); /* 初期住所をセレクト */
-
- if( fname[ 0 ] != NULL )
- {
- command = 'F';
- ExecCommand();
- };
- MainLoop(); /* メインループ */
- UnchainAMethod( &mTMenu ); /* 先に表選択メニューMethodをはずす */
- UnchainMethod(); /* Methodを登録から外す */
- CloseWindow(&mainWin); /* ウインドウを閉じる */
- InitTable();
- Tini();
- if(( oprateMode == 2 ) || ( oprateMode == 4 ))
- {
- CdFileClose( );
- };
-
- return( 0 );
- }